﻿using AutoMapper;
using BaseProject.Domain.Models;
using BaseProject.Model.ViewModels;

namespace BaseProject.Mapping
{
    public static class MappingExtensions
    {
        public static TDestination MapTo<TSource, TDestination>(this TSource source)
        {
            return Mapper.Map<TSource, TDestination>(source);
        }

        public static TDestination MapTo<TSource, TDestination>(this TSource source, TDestination destination)
        {
            return Mapper.Map(source, destination);
        }

        #region 用户相关

        public static UserVM ToModel(this User entity)
        {
            return entity.MapTo<User, UserVM>();
        }

        public static User ToEntity(this UserVM model)
        {
            return model.MapTo<UserVM, User>();
        }

        public static User ToEntity(this UserVM model, User destination)
        {
            return model.MapTo(destination);
        }

        #endregion 用户相关
    }
}